﻿@*
    For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
*@
@{
	Layout = null;
}
<link href="~/lib/layui/css/layui.css" rel="stylesheet" />
<script src="~/lib/layui/layui.js"></script>
<script src="~/js/js.cookie.js"></script>
<script src="~/js/moment.js"></script>
<script src="~/lib/jquery/dist/jquery.js"></script>

<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<title>Demo</title>

	<!-- 请勿在项目正式环境中引用该 layui.css 地址 -->
	@* <link href="//unpkg.com/layui@2.9.18/dist/css/layui.css" rel="stylesheet"> *@
</head>
<body>

	<form class="layui-form">
		<div class="layui-form-item">
			<div class="layui-inline">
				<table>
					<tr>
						<td>
							<label class="layui-form-label">入库单编码</label>
							<div class="layui-input-inline layui-input-wrap">
								<input type="text" id="storehousesNo" name="storehousesNo" placeholder="入库单编码" class="layui-input" style="width:300px;">
							</div>
						</td>

						<td>
							<div class="layui-form-item">
								<label class="layui-form-label">入库类型</label>
								<div class="layui-input-block">
									<select id="storehousesType" name="storehousesType" lay-filter="aihao" style="width:300px;">
										<option value="请选择">请选择</option>
										<option value="采购入库">采购入库</option>
										<option value="杂项入库">杂项入库</option>
										<option value="采购退货">采购退货</option>
										<option value="工厂入库">工厂入库</option>
										<option value="委外入库">委外入库</option>
										<option value="委外退货">委外退货</option>

									</select>
								</div>
							</div>
						</td>

					</tr>

					<tr>
						<td>
							<div class="layui-form-item">
								<label class="layui-form-label">仓库</label>
								<div class="layui-input-block">
									<select id="storehouseName" name="storehouseName" lay-filter="aihao" style="width:300px;">
										<option value="请选择">请选择</option>
										<option value="北京仓库">北京仓库</option>
										<option value="上海仓库">上海仓库</option>

									</select>
								</div>
							</div>
						</td>
						<td>
							<div class="layui-form-item">
								<label class="layui-form-label">仓库地址</label>
								<div class="layui-input-inline layui-input-wrap">
									<input type="text" id="storehouseAdd" name="storehouseAdd" placeholder="备注" class="layui-input" style="width:300px;">
								</div>
							</div>
						</td>
					</tr>

					<tr>
						<td>
							<div class="layui-inline">
								<div class="layui-form-item">
									<div class="layui-inline">
										<label class="layui-form-label">入库日期</label>
										<div class="layui-input-inline layui-input-wrap">
											<div class="layui-input-prefix">
												<i class="layui-icon layui-icon-date"></i>
											</div>
											<input type="date" name="storehouseTime" lay-verify="date" autocomplete="off" class="layui-input">
										</div>
									</div>
								</div>
							</div>
						</td>
						<td>
							<div class="layui-form-item">
								<label class="layui-form-label">备注</label>
								<div class="layui-input-inline layui-input-wrap">
									<input type="text" id="storehouseSmark" name="storehouseSmark" placeholder="备注" class="layui-input" style="width:300px;">
								</div>
							</div>
						</td>
					</tr>


					<tr>
						<td>
							<div class="layui-form-item layui-form-text">
								<label class="layui-form-label">入库来源</label>
								<div class="layui-input-block">
									<select id="storehouseCome" name="storehouseCome" lay-filter="aihao" style="width:300px;">
										<option value="请选择">请选择</option>
										<option value="采购订单">采购订单</option>

									</select>
								</div>
							</div>
						</td>
						<td>
							<label class="layui-form-label">采购订单编码</label>
							<div class="layui-input-inline layui-input-wrap">
								<input type="text" id="storehouseNum" name="storehouseNum" placeholder="采购订单编码" class="layui-input" style="width:300px;">
							</div>
						</td>
					</tr>


					<tr>
						<td>
							<div class="layui-form-item layui-form-text">
								<label class="layui-form-label">采购订单名称</label>
								<div class="layui-input-block">
									<textarea placeholder="采购订单名称" id="storehouseMy" name="storehouseMy" class="layui-textarea" style="width:300px;"></textarea>
								</div>
							</div>
						</td>
					</tr>




					<tr>
						<td>
							<div class="layui-form-item">
								<label class="layui-form-label">供应商</label>
								<div class="layui-input-block">
									<div class="layui-input-inline layui-input-wrap">
										<input type="text" id="storehouseShop" name="storehouseShop" placeholder="供应商" class="layui-input" style="width:300px;">
									</div>
								</div>
							</div>
						</td>
						<td>
							<label class="layui-form-label">供应商联系人</label>
							<div class="layui-input-block">
								<div class="layui-input-inline layui-input-wrap">
									<input type="text" id="shopPro" name="shopPro" placeholder="供应商联系人" class="layui-input" style="width:300px;">
								</div>
							</div>
						</td>
					</tr>

					<tr>
						<td>
							<div class="layui-form-item">
								<label class="layui-form-label">质检状态</label>
								<div class="layui-input-block">
									<div class="layui-input-inline layui-input-wrap">
										<input type="text" id="smark" name="smark" placeholder="质检状态" class="layui-input" style="width:300px;">
									</div>
								</div>
							</div>
						</td>
						<td>
							<label class="layui-form-label">入库状态</label>
							<div class="layui-input-block">
								<div class="layui-input-inline layui-input-wrap">
									<input type="text" id="storehouseGo" name="storehouseGo" placeholder="入库状态" class="layui-input" style="width:300px;">
								</div>
							</div>
						</td>
					</tr>



					<tr>
						<td>
							<label class="layui-form-label">制单人</label>
							<div class="layui-input-inline layui-input-wrap">
								<input type="text" id="storehousePro" name="storehousePro" placeholder="制单人" class="layui-input" style="width:300px;">
							</div>
						</td>
						<td>
							<div class="layui-form-item">
								<label class="layui-form-label">制单部门</label>
								<div class="layui-input-block">
									<select id="storehouseDep" name="storehouseDep" lay-filter="aihao" style="width:300px;">
										<option value="请选择">请选择</option>
										<option value="ERP公司C#组">ERP公司C#组</option>

									</select>
								</div>
							</div>
						</td>
					</tr>
				</table>
				<div class="layui-form-item">
					<div class="layui-input-block">
						<button type="submit" class="layui-btn" lay-submit lay-filter="demo1">修改</button>
					</div>
				</div>
			</div>
		</div>
	</form>
</body>
</html>



<script>
	  layui.use(['form', 'laydate', 'util'], function () {
		var form = layui.form;


			var upload = layui.upload;

			var laypage = layui.laypage;
			var $ = layui.$;
			var layer = layui.layer;
			var util = layui.util;




			 // 表单取值
		layui.$('#component').on('click', function () {
			var data = form.val('demo-val-filter');
		});


		// 提交事件
		form.on('submit(demo1)', function (d) {
			var data = {
					storehousesId:localStorage.getItem("storehousesId"),
				storehousesNo: $("#storehousesNo").val(),
				storehousesType: $("#storehousesType").val(),
				storehouseName: $("#storehouseName").val(),
				storehouseAdd: $("#storehouseAdd").val(),
				storehouseTime: $("input[name='storehouseTime']").val(),
				storehouseSmark: $("#storehouseSmark").val(),
				storehouseCome: $("#storehouseCome").val(),
				storehouseNum: $("#storehouseNum").val(),
				storehouseMy: $("#storehouseMy").val(),
				storehouseShop: $("#storehouseShop").val(),
				shopPro: $("#shopPro").val(),
				smark: $("#smark").val(),
				storehouseGo: $("#storehouseGo").val(),
				storehousePro: $("#storehousePro").val(),
				storehouseDep: $("#storehouseDep").val(),

			};
			$.ajax({
			url:'@ViewBag.RBACWrite' + "/api/Storehouse/updateStorehouse",
				type: 'put',
				data: JSON.stringify(data),
				dataType: "json",
				contentType: "application/json",
				success: res => {
					if (res.code == 0) {
						layer.msg('修改成功')
						 location.href = "ShowStorehouses"
					}
					else {
						layer.msg('修改失败')
					}
				}
			})
			return false; // 阻止默认 form 跳转
		});

	});

	GetWorkCenter()

		//工作中心返填
		function GetWorkCenter() {
			var workCenterId = localStorage.getItem("storehousesId")       // 正确地使用冒号来定义对象属性
			console.log(workCenterId);
			$.ajax({
					url: '@ViewBag.RBACWrite' + "/api/Storehouse/findStorehouse",
				type: "post",
				data: JSON.stringify({ storehousesId: workCenterId }),
				dataType: "json",
				async: false,
				contentType: "application/json",
				success: function (res) {
					console.log(res);
					$(res.data).each(function () {
						console.log("返填数据", res.data);

						  res.data.storehouseTime = moment(res.data.storehouseTime).format("YYYY-MM-DD")

						$("#storehousesId").val(this.storehousesId);

						$("#storehousesNo").val(this.storehousesNo);
						$("#storehousesType").val(this.storehousesType);
						$("#storehouseName").val(this.storehouseName);
						$("#storehouseAdd").val(this.storehouseAdd);
						$("#storehouseTime").val(this.storehouseTime);
						$("#storehouseSmark").val(this.storehouseSmark);
						$("#storehouseCome").val(this.storehouseCome);
						$("#storehouseNum").val(this.storehouseNum);

						$("#storehouseMy").val(this.storehouseMy);
						$("#storehouseShop").val(this.storehouseShop);
						$("#shopPro").val(this.shopPro);

						$("#smark").val(this.smark);
						$("#storehouseGo").val(this.storehouseGo);
						$("#storehousePro").val(this.storehousePro);
						$("#storehouseDep").val(this.storehouseDep);
					})
				}
			})
		}


</script>